/////////////////////////////////////////////////////////////////////////////
// Name:        testgrid.cpp
// Purpose:     
// Author:      Aleksey Plotnikov
// Modified by: 
// Created:     01/03/2011 08:56:22
// RCS-ID:      
// Copyright:   Diamant Group
// Licence:     
/////////////////////////////////////////////////////////////////////////////

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

////@begin includes
////@end includes

#include "testgrid.h"

////@begin XPM images
////@end XPM images


#include <wx/arrimpl.cpp>

/**********************************************************************************************/
WX_DEFINE_OBJARRAY( TestFunctionArray );



/*!
 * TestGrid type definition
 */

IMPLEMENT_DYNAMIC_CLASS( TestGrid, wxGrid )


/*!
 * TestGrid event table definition
 */

BEGIN_EVENT_TABLE( TestGrid, wxGrid )

////@begin TestGrid event table entries
////@end TestGrid event table entries

END_EVENT_TABLE()


/*!
 * TestGrid constructors
 */

TestGrid::TestGrid()
{
    Init();
}

TestGrid::TestGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
    Init();
    Create(parent, id, pos, size, style);
}


/*!
 * TestGrid creator
 */

bool TestGrid::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
{
////@begin TestGrid creation
    wxGrid::Create(parent, id, pos, size, style);
    CreateControls();
////@end TestGrid creation

	m_TestCount = 0;

    return true;
}


/*!
 * TestGrid destructor
 */

TestGrid::~TestGrid()
{
////@begin TestGrid destruction
////@end TestGrid destruction
}


/*!
 * Member initialisation
 */

void TestGrid::Init()
{
////@begin TestGrid member initialisation
////@end TestGrid member initialisation
}


/*!
 * Control creation for TestGrid
 */

void TestGrid::CreateControls()
{    
////@begin TestGrid content construction
////@end TestGrid content construction
}


/*!
 * Should we show tooltips?
 */

bool TestGrid::ShowToolTips()
{
    return true;
}

/*!
 * Get bitmap resources
 */

wxBitmap TestGrid::GetBitmapResource( const wxString& name )
{
    // Bitmap retrieval
////@begin TestGrid bitmap retrieval
    wxUnusedVar(name);
    return wxNullBitmap;
////@end TestGrid bitmap retrieval
}

/*!
 * Get icon resources
 */

wxIcon TestGrid::GetIconResource( const wxString& name )
{
    // Icon retrieval
////@begin TestGrid icon retrieval
    wxUnusedVar(name);
    return wxNullIcon;
////@end TestGrid icon retrieval
}


/**********************************************************************************************/
// Function for setting mode of grid
void TestGrid::set_GridMode( void )
{
	SetColSize(0,220);
	SetColSize(1,50);
	SetColSize(2,70);
	SetColLabelValue(0,_T("Test name"));
	SetColLabelValue(1,_T("Enable"));
	SetColLabelValue(2,_T("Passed"));
	wxGridCellAttr* pAttr = new wxGridCellAttr();
	pAttr->SetRenderer( new wxGridCellBoolRenderer() );
	pAttr->SetEditor( new wxGridCellBoolEditor() );
	pAttr->SetAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
	SetColAttr( 1, pAttr );
}


/**********************************************************************************************/
// Function for add test to window
void TestGrid::add_Test( TestItem_Ptr item )
{
	// get test information
	wxString testName = item->get_TestName();
	m_FuncArray[ m_TestCount ] = item->get_TestFunction();

	// get row number
	unsigned row = m_TestCount + 1;

	// set test info to grid
	SetCellValue( testName, row, 0 );
	SetReadOnly( row, 0 );
	SetReadOnly( row, 2 );
	SetCellValue( _T( "1" ), row, 1);


	m_TestCount++;
}